/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package idea.sfo.viewer.graphics;


import designersfo.Cons.CellInfo.CellFormat;
import idea.model.qnrlibrary.CustomResponses;
import idea.model.qnrlibrary.DcAttributeGroup;
import idea.model.qnrlibrary.PaperAttributeGroup;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;


/**
 *
 * @author renke002
 */
public class CheckboxField extends ContentLayout
{

    /**
     *
     */
    private final static float CHECKBOX_LINE_THICKNESS = (float) 0.007;
    /**
     *
     */
    private final static float CHECKBOX_SIZE_BACKGROUND = (float) 0.202;
    /**
     *
     */
    private final static float CHECKBOX_SIZE_INNER_BOX = (float) 0.11;
    /**
     *
     */
    private Rectangle innerBorder;
    /**
     *
     */
    private Rectangle innerBox;
    /**
     *
     */
    private Rectangle outerBox;


    /**
     *
     * @param cResponses
     * @param dcAttrGroup
     * @param paperAttrGroup
     * @param container
     * @param cellFormat
     */
    CheckboxField( CustomResponses cResponses ,
            DcAttributeGroup dcAttrGroup ,
            PaperAttributeGroup paperAttrGroup ,
            Rectangle container ,
            CellFormat cellFormat )
    {
        //
        this.placeContent( container );
    }


    /**
     *
     * @param g2d
     */
    @Override
    public void draw( Graphics2D g2d )
    {
        //
        g2d.setColor( Color.WHITE );
        g2d.fill( this.outerBox );
        //
        g2d.setColor( Color.BLACK );
        g2d.draw( this.innerBorder );
        //
        g2d.setColor( Color.WHITE );
        g2d.fill( this.innerBox );
    }


    /**
     *
     * @return
     */
    @Override
    public String getLabel()
    {
        return "Checkbox";
    }


    /**
     *
     * @param container
     */
    private void placeContent( Rectangle container )
    {
        // outer.
        int outerBoxSize = 18;
        int midBoxSize = 10;
        int innerBoxSize = 8;

        Dimension outerBoxDim = new Dimension( outerBoxSize , outerBoxSize );
        Point anchorPoint = ContentLayout.placeContent(
                container ,
                outerBoxDim ,
                ContentLayout.HORIZONTAL_NAME_CENTER ,
                ContentLayout.VERTICAL_NAME_TOP );

        this.outerBox = new Rectangle(
                anchorPoint.x ,
                anchorPoint.y ,
                outerBoxSize ,
                outerBoxSize );

        //
        int shift = ( outerBoxSize - midBoxSize ) / 2;
        this.innerBorder = new Rectangle(
                anchorPoint.x + shift ,
                anchorPoint.y + shift ,
                midBoxSize ,
                midBoxSize );

        //
        shift = ( outerBoxSize - innerBoxSize ) / 2;
        this.innerBox = new Rectangle(
                anchorPoint.x + shift ,
                anchorPoint.y + shift ,
                innerBoxSize ,
                innerBoxSize );
    }

}
